package com.gitee.qdbp.general.common.biz.sequence.service.model;

import com.gitee.qdbp.base.annotation.OperateTraces;
import com.gitee.qdbp.general.common.api.sequence.model.SimpleSequenceRule;

@OperateTraces(id = "type", desc = "name")
public class SimpleSequenceParams extends SimpleSequenceRule {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    /** 类型 **/
    private String type;

    /** 子类型 **/
    private String subtype;

    /** 类型 **/
    public String getType() {
        return type;
    }

    /** 类型 **/
    public void setType(String type) {
        this.type = type;
    }

    /** 子类型 **/
    public String getSubtype() {
        return subtype;
    }

    /** 子类型 **/
    public void setSubtype(String subtype) {
        this.subtype = subtype;
    }

    /**
     * 将当前对象转换为子类对象
     *
     * @param clazz 目标类型
     * @return 目标对象
     */
    public <T extends SimpleSequenceRule> T to(Class<T> clazz) {
        T instance = super.to(clazz);

        if (instance instanceof SimpleSequenceParams) {
            SimpleSequenceParams real = (SimpleSequenceParams) instance;
            real.setSubtype(this.getSubtype()); // 子类型
            real.setType(this.getType()); // 类型
        }

        return instance;
    }

}
